#include "tabbutton.h"
#include "../terminalglobals.h"
#include <QPainter>

using namespace ExecTerminalImplNS;

TabButton::TabButton(QWidget * parent): TabBarTab(parent)
{

}

TabButton::TabButton(const QString & text, QWidget * parent): TabBarTab(text, parent)
{

}

TabButton::TabButton( const QIcon & icon, const QString & text, QWidget * parent): TabBarTab(icon, text, parent)
{


}

void TabButton::drawTabBackground(QPainter * painter)
{
    QPixmap leftPix;
    QPixmap centerPix;
    QPixmap rightPix;
    if (isChecked())
    {
        leftPix = pixmapForPath(":Resources/left_bookmarks_active_left.png");
        centerPix = pixmapForPath(":Resources/left_bookmarks_active_center.png");
        rightPix = pixmapForPath(":Resources/left_bookmarks_active_right.png");
    }
    else if (underMouse())
    {
        leftPix = pixmapForPath(":Resources/left_bookmarks_left_hover.png");
        centerPix = pixmapForPath(":Resources/left_bookmarks_center_hover.png");
        rightPix = pixmapForPath(":Resources/left_bookmarks_right_hover.png");
    }
    else
    {
        leftPix = pixmapForPath(":Resources/left_bookmarks_left.png");
        centerPix = pixmapForPath(":Resources/left_bookmarks_center.png");
        rightPix = pixmapForPath(":Resources/left_bookmarks_right.png");
    }
    painter->drawPixmap(0, 0, leftPix);
    const QRect rectForTile(0 + leftPix.width(), 0, width() - leftPix.width() - rightPix.width(), height());
    painter->drawTiledPixmap(rectForTile, centerPix);
    painter->drawPixmap(rectForTile.x() + rectForTile.width(), 0,  rightPix);
}

